 //
//  GameLayer.h
//  Demo
//
//  Created by CG on 13-10-3.
//
//

#ifndef Demo_GameLayer_h
#define Demo_GameLayer_h


#include "Utils.h"
#include "cocos2d.h"
#include "Box2d.h"


#include "Ball.h"
#include "Obstacle.h"
#include "Bucket.h"

#include "GLES-Render.h"
#include "MyContactListener.h"



using namespace cocos2d;

class GameLayer : public cocos2d::CCLayer {
public:
    GameLayer();
    ~GameLayer();
    
    bool init();
    void update(float dt);
    void updateBox2dWorld(float dt);
    
    virtual bool ccTouchBegan(CCTouch* pTouch, CCEvent *pEvent);
    virtual void ccTouchMoved(CCTouch* pTouch, CCEvent *pEvent);
    virtual void ccTouchEnded(CCTouch* pTouch, CCEvent *pEvent);
    virtual void ccTouchCancelled(CCTouch* pTouch, CCEvent *pEvent);
    
    void CreateGround();
    void CreateLayout();
    void CreateBalls();
    void CreateObstacles();
    void CreateBucket();

    
    virtual void draw();

    void handleCollision();
    
private:
    b2World* m_pWorld;
    
    GLESDebugDraw* debugDraw;
    
    
};

#endif
